.class public Lcom/glympse/platform/common/TwitterJobs$SignInJob;
.super Lcom/glympse/platform/common/OAuthJob;
.source "TwitterJobs.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/glympse/platform/common/TwitterJobs;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "SignInJob"
.end annotation


# instance fields
.field private m_oSignInCallback:Lcom/glympse/platform/common/TwitterJobs$SignInCallback;

.field private m_strTwitterName:Ljava/lang/String;


# direct methods
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Lcom/glympse/platform/common/TwitterJobs$SignInCallback;)V
    .locals 8
    .parameter "strUsername"
    .parameter "strPassword"
    .parameter "oSignInCallback"

    .prologue
    const/4 v0, 0x1

    const/4 v5, 0x0

    .line 37
    invoke-direct {p0}, Lcom/glympse/platform/common/OAuthJob;-><init>()V

    .line 33
    iput-object v5, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_strTwitterName:Ljava/lang/String;

    .line 34
    iput-object v5, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_oSignInCallback:Lcom/glympse/platform/common/TwitterJobs$SignInCallback;

    .line 39
    iput-boolean v0, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fCompleteOnMainThread:Z

    .line 40
    iput-boolean v0, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fReadResponseForFailedCall:Z

    .line 42
    iput-object p1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_strTwitterName:Ljava/lang/String;

    .line 43
    iput-object p3, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_oSignInCallback:Lcom/glympse/platform/common/TwitterJobs$SignInCallback;

    .line 46
    new-instance v7, Lcom/glympse/platform/GVector$NameValueNodes;

    invoke-direct {v7}, Lcom/glympse/platform/GVector$NameValueNodes;-><init>()V

    .line 47
    .local v7, listParams:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    new-instance v0, Lcom/glympse/platform/common/NameValueNode;

    const-string v1, "x_auth_mode"

    const-string v2, "client_auth"

    invoke-direct {v0, v1, v2}, Lcom/glympse/platform/common/NameValueNode;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v7, v0}, Lcom/glympse/platform/GVector$NameValueNodes;->addElement(Ljava/lang/Object;)V

    .line 48
    new-instance v0, Lcom/glympse/platform/common/NameValueNode;

    const-string v1, "x_auth_password"

    invoke-direct {v0, v1, p2}, Lcom/glympse/platform/common/NameValueNode;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v7, v0}, Lcom/glympse/platform/GVector$NameValueNodes;->addElement(Ljava/lang/Object;)V

    .line 49
    new-instance v0, Lcom/glympse/platform/common/NameValueNode;

    const-string v1, "x_auth_username"

    invoke-direct {v0, v1, p1}, Lcom/glympse/platform/common/NameValueNode;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v7, v0}, Lcom/glympse/platform/GVector$NameValueNodes;->addElement(Ljava/lang/Object;)V

    .line 52
    const/4 v1, 0x0

    .line 53
    const-string v2, "https://api.twitter.com/oauth/access_token"

    .line 54
    const-string v3, "F1yA1TIxkIrJr7O3Rz1Pvg"

    const-string v4, "eJ2CBiBQMgRqFhpGGZFmwNhnMS3lwa2uQ1BvElsCOM"

    move-object v0, p0

    move-object v6, v5

    .line 52
    invoke-virtual/range {v0 .. v7}, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->SendOAuthRequest(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/glympse/platform/GVector$NameValueNodes;)V

    .line 57
    return-void
.end method


# virtual methods
.method public GetTokenAndScreenName()Z
    .locals 7

    .prologue
    .line 120
    const/4 v3, 0x0

    .line 121
    .local v3, strToken:Ljava/lang/String;
    const/4 v4, 0x0

    .line 123
    .local v4, strTokenSecret:Ljava/lang/String;
    iget-object v5, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_abResponse:[B

    if-eqz v5, :cond_1

    .line 125
    iget-object v5, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_abResponse:[B

    invoke-static {v5}, Lcom/glympse/platform/Platform;->ByteArrayToString([B)Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/glympse/platform/common/Helpers;->ParseQueryStringParameters(Ljava/lang/String;)Lcom/glympse/platform/GVector$NameValueNodes;

    move-result-object v1

    .line 127
    .local v1, listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    invoke-virtual {v1}, Lcom/glympse/platform/GVector$NameValueNodes;->elements()Ljava/util/Enumeration;

    move-result-object v0

    .local v0, iter:Ljava/util/Enumeration;
    :cond_0
    :goto_0
    invoke-interface {v0}, Ljava/util/Enumeration;->hasMoreElements()Z

    move-result v5

    if-nez v5, :cond_2

    .line 158
    .end local v0           #iter:Ljava/util/Enumeration;
    .end local v1           #listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    :cond_1
    if-eqz v3, :cond_5

    if-eqz v4, :cond_5

    .line 160
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v5

    iget-object v5, v5, Lcom/glympse/platform/Platform;->m_oConfig:Lcom/glympse/platform/Config;

    iget-object v6, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_strTwitterName:Ljava/lang/String;

    invoke-virtual {v5, v6, v3, v4}, Lcom/glympse/platform/Config;->SetTwitterToken(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 161
    const/4 v5, 0x1

    .line 163
    :goto_1
    return v5

    .line 129
    .restart local v0       #iter:Ljava/util/Enumeration;
    .restart local v1       #listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    :cond_2
    invoke-interface {v0}, Ljava/util/Enumeration;->nextElement()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/glympse/platform/common/NameValueNode;

    .line 131
    .local v2, oCur:Lcom/glympse/platform/common/NameValueNode;
    iget-object v5, v2, Lcom/glympse/platform/common/NameValueNode;->m_strName:Ljava/lang/String;

    invoke-static {v5}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v5

    if-nez v5, :cond_0

    iget-object v5, v2, Lcom/glympse/platform/common/NameValueNode;->m_strValue:Ljava/lang/String;

    invoke-static {v5}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v5

    if-nez v5, :cond_0

    .line 134
    iget-object v5, v2, Lcom/glympse/platform/common/NameValueNode;->m_strName:Ljava/lang/String;

    const-string v6, "oauth_token"

    invoke-virtual {v5, v6}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_3

    .line 136
    iget-object v3, v2, Lcom/glympse/platform/common/NameValueNode;->m_strValue:Ljava/lang/String;

    goto :goto_0

    .line 140
    :cond_3
    iget-object v5, v2, Lcom/glympse/platform/common/NameValueNode;->m_strName:Ljava/lang/String;

    const-string v6, "oauth_token_secret"

    invoke-virtual {v5, v6}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_4

    .line 142
    iget-object v4, v2, Lcom/glympse/platform/common/NameValueNode;->m_strValue:Ljava/lang/String;

    goto :goto_0

    .line 148
    :cond_4
    iget-object v5, v2, Lcom/glympse/platform/common/NameValueNode;->m_strName:Ljava/lang/String;

    const-string v6, "screen_name"

    invoke-virtual {v5, v6}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_0

    .line 150
    iget-object v5, v2, Lcom/glympse/platform/common/NameValueNode;->m_strValue:Ljava/lang/String;

    iput-object v5, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_strTwitterName:Ljava/lang/String;

    goto :goto_0

    .line 163
    .end local v0           #iter:Ljava/util/Enumeration;
    .end local v1           #listNameValues:Lcom/glympse/platform/GVector$NameValueNodes;,"Lcom/glympse/platform/GVector$NameValueNodes;"
    .end local v2           #oCur:Lcom/glympse/platform/common/NameValueNode;
    :cond_5
    const/4 v5, 0x0

    goto :goto_1
.end method

.method public OnComplete(Lcom/glympse/platform/common/JobQueue;)V
    .locals 4
    .parameter "oJobQueue"

    .prologue
    const/16 v3, 0x2e

    .line 63
    invoke-virtual {p0}, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->DumpDownload()V

    .line 65
    const/4 v0, 0x0

    .line 68
    .local v0, strError:Ljava/lang/String;
    iget-boolean v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fSuccess:Z

    if-eqz v1, :cond_4

    .line 70
    invoke-virtual {p0}, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->GetTokenAndScreenName()Z

    move-result v1

    iput-boolean v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fSuccess:Z

    .line 80
    :cond_0
    :goto_0
    iget-boolean v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fSuccess:Z

    if-nez v1, :cond_1

    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 83
    iget-boolean v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fSuccess:Z

    if-nez v1, :cond_1

    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 90
    const/16 v1, 0x191

    iget v2, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_nResultCode:I

    if-ne v1, v2, :cond_5

    .line 92
    const-string v0, "Invalid user name or password."

    .line 105
    :cond_1
    :goto_1
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->IsEmpty(Ljava/lang/String;)Z

    move-result v1

    if-nez v1, :cond_2

    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v1

    const/4 v2, 0x1

    sub-int/2addr v1, v2

    invoke-virtual {v0, v1}, Ljava/lang/String;->charAt(I)C

    move-result v1

    if-eq v3, v1, :cond_2

    .line 107
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-static {v0}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 111
    :cond_2
    iget-object v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_oSignInCallback:Lcom/glympse/platform/common/TwitterJobs$SignInCallback;

    if-eqz v1, :cond_3

    .line 113
    iget-object v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_oSignInCallback:Lcom/glympse/platform/common/TwitterJobs$SignInCallback;

    iget-boolean v2, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_fSuccess:Z

    invoke-interface {v1, v2, v0}, Lcom/glympse/platform/common/TwitterJobs$SignInCallback;->SignInComplete(ZLjava/lang/String;)V

    .line 115
    :cond_3
    return-void

    .line 74
    :cond_4
    iget-object v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_abResponse:[B

    if-eqz v1, :cond_0

    iget-object v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_abResponse:[B

    array-length v1, v1

    if-lez v1, :cond_0

    .line 76
    iget-object v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_abResponse:[B

    invoke-static {v1}, Lcom/glympse/platform/Platform;->ByteArrayToString([B)Ljava/lang/String;

    move-result-object v0

    goto :goto_0

    .line 94
    :cond_5
    iget v1, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_nResultCode:I

    if-lez v1, :cond_6

    .line 96
    new-instance v1, Ljava/lang/StringBuilder;

    const-string v2, "Twitter responded with an error ("

    invoke-direct {v1, v2}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget v2, p0, Lcom/glympse/platform/common/TwitterJobs$SignInJob;->m_nResultCode:I

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, ")."

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    goto :goto_1

    .line 100
    :cond_6
    const-string v0, "Twitter responded with an error."

    goto :goto_1
.end method
